<?php use_helper('PA_Links') ?>
<?php if(isset($orders) ? ($orders->count() > 0 ? true : false ) : false): ?>
  <table id="inline_table">
    <tr>
    <th> Lp. </th>
    <th> Symbol </th>
    <th> Firma </th>
    <th> Status </th>
    <th> Adres dostawy </th>
    <th> Projekt </th>
    <th> Użytkownik </th>
    <th> Kategoria </th>
    <th> Wysłano </th>
    <th> Edycja i narzędzia</th>
    </tr>
  <?php foreach($orders as $order): ?>
    <tr>
      <td><p id="counter"></p></td>
      <td nowrap="nowrap">
        <a onclick="App.loadWindow('<?php echo link_to_app('Store', 'showOrder', array('id' => $order->getId())) ?>')" class="middle"><?php echo $order->getNumber() ?></a>
      </td>
      <td><?php echo $order->getDeliverer() ?></td>
      <td id="status_<?php echo $order->getStatus() ?>"><?php echo $status[$order->getStatus()] ?></td>
      <td nowrap="nowrap"><?php echo $order->getTargetAddress() ?></td>
      <td nowrap="nowrap"><?php echo $order->getDemand()->getProject()->getName() ?></td>
      <td nowrap="nowrap"><?php echo $order->getUser() ?></td>
      <td><?php echo !$order->getDemand()->getCategory()  ? : '-'  ?></td>
      <td nowrap="nowrap"><?php echo $order->getCreatedAt() ?></td>
      <td nowrap="nowrap">
        <?php if(in_array($order->getStatus(), array(1, 2, 10))): ?>
        <a href="<?php echo link_to_app('Store', 'updateOrder', array('id' => $order->getId())) ?>" class="middle">Aktualizuj</a>
        <?php endif; ?>
        <?php if($order->getStatus() == 0): ?>
        <img src="/images/icons/send.png" class="middle" width="16" height="16"/>
        <a href="<?php echo link_to_app('Store', 'sendOrder', array('id' => $order->getId())) ?>" class="middle">Wyślij</a>
        <?php endif; ?>
        <?php if($sf_user->hasCredential('admin')): ?>
        <img src="/images/icons/delete.png" class="middle" width="16" height="16"/>  <a href="<?php echo link_to_app('Store', 'deleteOrder', array('id' => $order->getId())) ?>" class="middle">Usuń</a>
        <?php else: ?>
        <img src="/images/icons/delete_inactive.png" class="middle" width="16" height="16"/> <a class="middle">Usuń</a>
        <?php endif; ?>
      </td>
    </tr>
  <?php endforeach; ?>
  </table>
<?php else: ?>
  Brak dokumentów.
<?php endif; ?>
